#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int T;
int n,m,L,V,ans1,ans2;
int d,va,a;
int p[N];
bool flag[N];
struct node{
    int d;
    int v;
    int a;
}car[N];
bool check(int vv,int aa,int ss,int VV){
    if((vv*vv + 2*aa*ss) < 0)
        return false;
    double cnt = double(sqrt(vv * vv + 2 * aa *ss));
    if(cnt > VV)
        return true;
    return false;
}
void inint(){
    ans1 = 0;
    ans2 = 0;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        inint();
        cin>>n>>m>>L>>V;
        for(int i = 1;i<=n;i++)
            cin>>car[i].d>>car[i].v>>car[i].a;
        for(int i = 1;i<=m;i++)
            cin>>p[i];
        for(int i = 1;i<=n;i++){
            for(int j = 1;j<=m;j++){
                if(check(car[i].v,car[i].a,(p[j] - car[i].d),V) && p[j]>=car[i].d){
                    ans1++;
                    flag[j] = 1;
                    break;
                }
            }
        }
        for(int i = 1;i<=m;i++)
            if(!flag[i])
                ans2++;
        cout<<ans1<<" "<<ans2;
    }
    return 0;
}
